#include<stdio.h>
#include<string.h>

int main()
{
    FILE *fp = fopen("log.txt", "w");
    if(!fp)
    {
        perror("fopen:");
        return 1;
    }

    const char *msg = "hello bit: ";
    int count = 1;
    while(count <= 10)
    {
        char buffer[1024];
        snprintf(buffer, sizeof(buffer), "%s%d\n", msg, count++);
        fwrite(buffer, strlen(buffer), 1, fp);
    }

    fclose(fp);

    return 0;
}
